<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>map</title>
</head>
<body>
	<script type="text/javascript">
		var array=[1,2,3,4];
		var sqArr=array.map(function(item){
			return item*item;
		})
		console.log(sqArr);
		var filterArr=array.filter(function(item){
			return item>2;
		})
		console.log(filterArr);
		var someArr=array.some(function(item){
			return item>2
		})
		console.log(someArr);
		var everyArr=array.every(function(item){
			return item>2
		})
		// console.log(everyArr);
		// console.log(array.indexOf(3));//2
		// console.log(array.indexOf("3"));//-1 3 !== "3"
		// console.log(array.indexOf(3,1));//2
		// console.log(array.indexOf(3,-2));//2
		// console.log(array.indexOf(3,-1));//-1没找到
		// console.log("===========================");
		// console.log(array.lastIndexOf(3));//2
		// console.log(array.lastIndexOf("3"));//-1 3 !== "3"
		// console.log(array.lastIndexOf(3,1));//-1没找到
		// console.log(array.lastIndexOf(3,-2));//2
		// console.log(array.lastIndexOf(3,-1));//2
		var sum=array.reduce(function(previous,current,index,array){
			console.log(previous+"=="+current+"=="+index)
			return  previous+current;
		},10)
		var matrix=[
			[1,2],
			[3,4],
			[5,6]
		];
		var flatten=matrix.reduce(function(previous,current){
			return previous.concat(current);
		})
		console.log(flatten)
		var specialDiff=array.reduceRight(function(previous,current,index){
			if (index==0) {
				return previous+current;
			}
			return previous-current;
		})
		console.log(specialDiff)
		var a=[];
		for (var i = 0; i < 10; i++) {
			a.push(i+1);
		}
		var sum=a.reduce(function(previous,current){
			return previous+"===="+current;
		})

		var arr =  [{"name":"brick11"},{"name":"brick12"},{"name":"brick13"},{"name":"brick14"}];
		var finArr=arr.reduce(function(previous,current,index,array){
			console.log(index+"oooooooooooooooooo")
			if (index===0) {
				return current.name;
			} else if (index===array.length-1) {
				return previous+"&"+current.name;
			} else {
				return previous+","+current.name;
			}
		},'')
		console.log(finArr)
	</script>
</body>
</html>